/**
 * https://www.luogu.com.cn/problem/P8772
 */

#include<iostream>
using namespace std;
typedef long long ll;
const int M=2*1e5+10;
int main()
{
	int a[M];
	int n;
	cin>>n;
	ll sum=0;
	for(int i=0;i<n;++i){
		cin>>a[i];
		sum+=a[i];
	}
	ll num=0;
	ll m=0;
	for(int i=0;i<n-1;++i){
		m+=(sum-num-a[i])*a[i];
		num+=a[i];
	}
	cout<<m<<endl;
	return 0;
}